#define _CRT_SECURE_NO_WARNINGS 1



#include<stdio.h>
#include<string.h>

void reverse(char* left, char* right)
{
	while (left < right)
	{
		char temp = *left;
		*left = *right;
		*right = temp;
		left++;
		right--;
	}
}
int main()
{
	char arr[2001] = { 0 }, a[1001] = { 0 }, b[1001] = { 0 };
	scanf("%s", arr);
	int len = strlen(arr), i = 0, x = 0, j = 0, flag = 1;
	for (i = 0; i < len; i++)
	{
		if (arr[i] >= 'A' && arr[i] <= 'Z')
		{
			flag = 0;
			break;
		}
	}
	if (flag == 1 && len > 1)
	{
		for (i = 0; i < len; i++)
		{
			if (arr[i] == '&')
			{
				x = i;
				break;
			}
		}
		for (i = 0; i < x; i++)
			a[i] = arr[i];
		for (i = x + 1, j = 0; i < len; i++, j++)
			b[j] = arr[i];
		reverse(a, a + x - 1);
		if (strcmp(a, b) == 0)
			printf("YES\n");
		else
			printf("NO\n");
	}
	else
		printf("NO\n");
		 
	return 0;
}